package cn.cmeizu.spring6.jdbc.xmltx.dao.impl;

import cn.cmeizu.spring6.jdbc.xmltx.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author cmeizu
 * @date 2023/2/12 23:08
 */
@Repository
public class UserDaoImpl implements UserDao {
  @Autowired
  private JdbcTemplate jdbcTemplate;

  @Override
  public void updateBalance(Integer userId, Long price) {
    String sql = "update t_user set balance = balance - ? where user_id = ?";
    Object[] params = {price, userId};
    jdbcTemplate.update(sql, params);
  }
}
